<!DOCTYPE html>
<html>

<head>
    <title>重设密码</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="target-densitydpi=device-dpi, width=400px, user-scalable=no" />
    <include file="Share:meta" />
<!--    <link rel="stylesheet" href="../Public/css/bizcard.css?v=20170118">
     <link rel="stylesheet" href="../Public/bootstrap/css/bootstrap.css">
    <link rel="stylesheet" href="../Public/font-awesome-4.4.0/css/font-awesome.css">
    <script type="text/javascript" src="../Public/plugins/jQuery/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="../Public/bootstrap/js/bootstrap.min.js"></script> -->
   
 
    <style type="text/css">
        .forgetForm .form-group{ border: 1px solid #6396c5; border-radius: 5px; padding: 3px 0px; }
        .forgetForm .form-control{ border: 0px; color: #6396c5; height: 45px; line-height: 45px; font-size: 18px; box-shadow:none;}
        .forgetForm .control-label{ height: 45px; line-height: 45px; overflow: hidden; color: #6396c5; font-size: 16px; margin-bottom: -5px;}
    </style>
    <link rel="stylesheet" href="../Public/css/WeUI/weui.css">
</head>

<body style="background-color: #fff;">
    <div class="container-fluid">
        <div class="row">
            <br>
            <br>
            <br>
            <form action="" method="post" class="forgetForm" enctype="multipart/form-data">
                <div class="row">
                    
                    <div class="col-xs-10 col-xs-offset-1">
                        <div class="form-group">
                            <div class="col-xs-3 npr">
                                <label for="input" class="control-label ">手机号码</label>
                            </div>
                            <div class="col-xs-9 np">
                                <input type="text" name="mobile" id="mobile" class="form-control" value="" required="required">
                            </div>
                            <div class="clearfix">
                            
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-10 col-xs-offset-1">
                        <div class="form-group">
                            <div class="col-xs-3 npr">
                                <label for="input" class="control-label ">验证码</label>
                            </div>
                            <div class="col-xs-5 np">
                                <input type="text" name="msgCode" id="input" class="form-control" value="" required="required">
                            </div>
                            <div class="col-xs-4 npl textright">
                                <label for="input" class="control-label "><button type="button" class="btn btn-default" id="send_sms" >发送验证码</button>

                                </label> 
                               
                            </div>
                            <div class="clearfix">
                            
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-10 col-xs-offset-1">
                        <div class="form-group">
                            <div class="col-xs-4 npr">
                                <label for="input" class="control-label ">输入新密码</label>
                            </div>
                            <div class="col-xs-8 np">
                                <input type="password" name="password" id="input" class="form-control" value="" required="required" >
                            </div>
                            <div class="clearfix">
                            
                            </div>
                        </div>
                    </div>

                    <div class="col-xs-10 col-xs-offset-1">
                        <div class="form-group">
                            <div class="col-xs-4 npr">
                                <label for="input" class="control-label ">确认新密码</label>
                            </div>
                            <div class="col-xs-8 np">
                                <input type="password" name="passwordConfirm" id="input" class="form-control" value="" required="required">
                            </div>
                            <div class="clearfix">
                            
                            </div>
                        </div>
                    </div>
                    
                    <div class="col-xs-10 col-xs-offset-1" style="margin-top: 30px;">
                        <input type="submit" name="" class="loginSubmit textcenter" style="border-radius: 5px; " value="保存">
                    </div>
                    <div class="col-xs-10 col-xs-offset-1" style="margin-top: 30px;">
                        <input type="button" name="" onclick="window.location.href='/Bizcard/login/hash/{$Think.get.hash}';" class="loginReg textcenter" style="border-radius: 5px;border: 1px solid #3b82c5; color: #3b82c5;" value="返回">
                    </div>
                </div>
            </form>
        </div>
    </div>
</body>
<include file="Share:toast" />
<script type="text/javascript">
    $(function(){
             //发送验证码
        $('#send_sms').click(function(){
            var mobile = $("#mobile").val();
            if (mobile =='' || typeof(mobile)=='undefined'){
                toast('请输入手机号码','warn');
                return;
            }
            if (isNaN(mobile) || mobile.length != 11) { 
                toast('请输入正确的手机号码','warn');
                return false;
            }
            var send_obj = $('#send_sms');
            if(mobile){
                $.ajax({
                    type: "GET",
                    url: "/Bizcard/checkMobileIsExists",
                    data: "mobile="+mobile,
                    dataType: "json",// html/json/jsonp/xml
                    success: function(result, opt){                
                       if (result.status == '1'){
                            toastLoading();
                            send_obj.attr('disabled',"disabled");
                              //60秒后重新启动发送按钮
                            startSmsButton(send_obj);
                              //发送短信
                            sendSMSVerify(mobile);
                       }else{
                            toast("该手机号码不存在", "warn");
                       }
                    },
                    error: function(){
                        toast("验证手机号码失败", "warn");
                    }
                });               
              
            }else{
              showMsg('手机号不能为空');
           }
        });
    });

    function startSmsButton(obj){
        var count = 1 ;
        var sum = 60;
        var i = setInterval(function(){
          if(count > sum){
            obj.attr('disabled',false);
            obj.html('发送验证码');
            clearInterval(i);
          }else{
            obj.html('剩余'+parseInt(sum - count)+'秒');
          }
          count++;
        },1000);
    };

    function sendSMSVerify(mobile){
        $.ajax({
            type: 'GET',
            url: '/Bizcard/sendMsg',
            data: {mobile:mobile},
            dataType:'json',
            timeout: 12000,
            beforeSend: function(){
                toastLoading();
            },complete: function(){
                toastClose();
            },
            success: function(result,opt){
                toast(result.msg, "success");
            },error: function(){
                toast('短信发送失败','warn');
            }
        })
    };

</script>
</html>
